//旧题数组新做：
#include<iostream>
using namespace std;
int main(){
  int a[5]={};
  int i,part,sum=0;
  for(i=0;i<5;i++)cin>>a[i];
  for(int i=0;i<5;i++){
    part=a[i]/3;
    a[(i+5+1)%5]+=part;
    a[(i+5-1)%5]+=part;
    sum+=a[i]%3;
    a[i]=part;
  }
  for(i=0;i<5;i++)cout<<a[i]<<" ";
  cout<<endl<<sum;

}